﻿CREATE PROCEDURE [dbo].[proc_Order_PaymentRecord_Getlist]
(
		@OId uniqueidentifier
	)
AS
begin
	;WITH list As(Select ROW_NUMBER() OVER (ORDER BY FinanceFlag)AS Row,
		Id
		,GId
		,OId
		,CusId
		,CusName
		,SalesmanAccount
		,Salesman
		,CreateDate
		,Prices
		,PaymentTypeId
		,PaymentType
		,BankId
		,Bank
		,SWId
		,SWName
,shjbh
		,FinanceFlag
		,ISnull(FinanceDate,'1900-01-01') As FinanceDate
		,CompanyId
		,[Description]
		,(SELECT SUM(Prices) FROM Order_PaymentRecord Where OId=@OId) AS Prices_SUM
		From Order_PaymentRecord 
		Where OId=@OId
	)
	Select * From list
end
